<?
#mulai bca.php
$url = "http://www.klikbca.com/corporate/Ind/rates.html" ;

$html_start = '<table border="0" cellspacing="0" cellpadding="0" class="testL">';
$html_end = '<!--- Mulai proses untuk yang BN----->';

ini_set ('allow_url_fopen', '1' );
ini_set ('auto_detect_line_endings', 'Off') ;
ini_set ('default_socket_timeout', '60' );
ini_set ('max_execution_time', '0' );

flush() ;

$f = fopen ($url, 'r' );

$doc = '';
while (! feof ($f) ) {
$doc = $doc . fgets($f, 3072) ;
// triple buffer, default buffer 1024 bytes dirubah menjadi 3072 bytes,
// krn di file $url dicek ada line yg panjang sekali, > 2 KB
}
fclose ($f) ;


if ($doc != '') {

$a = strpos($doc, $html_start) ;
$b = strpos($doc, $html_end) - $a ;
$show = substr($doc, $a, $b) ;
$show = ereg_replace($html_start, '<table border=1 cellspacing=0 cellpanding=0 width=100%>', $show) ;
$show = ereg_replace("bgcolor=\"#6699CC\"", "bgcolor=\"#ffcc00\"", $show) ;
$show = ereg_replace("bgcolor=\"#ff9c00\"", "bgcolor=\"#abbb97\"", $show) ;
$show = ereg_replace("white", "#000000", $show) ;
$show = ereg_replace("bgcolor='#e0e0e0'", "bgcolor=\"#ffffff\"", $show) ;
$show = ereg_replace("\"#0000a0\"", "#000000", $show) ;
$show = ereg_replace("<font color=\"#000000\" size=\"2\" face=\"Verdana\">", "<font face=\"Verdana\" style=\"font-size: 8pt\">", $show) ;
$show = ereg_replace("<font face=\"Arial\" size=\"2\" color=#000000>", "<font face=\"Verdana\" style=\"font-size: 8pt\">", $show) ;
$show = ereg_replace("<strong>DD/TT</strong>", "", $show) ;
$show = ereg_replace("<td colspan=\"3\">", "<td colspan=\"3\" bgcolor=\"#abbb97\">", $show) ;
$show = ereg_replace("Mata Uang", "Duit", $show) ;
$show = ereg_replace("<strong>Duit</strong>", "Kurs", $show) ;
$show = ereg_replace("<strong>Jual</strong>", "Jual", $show) ;
$show = ereg_replace("<strong>Beli</strong>", "Beli", $show) ;
$show = ereg_replace("<br>", "", $show) ;
$show = ereg_replace("&nbsp;", "", $show) ;
$show = ereg_replace("</font> </td>", "", $show) ;
$show = ereg_replace("</table>  <td>", "</table>", $show) ;

// print "$show" ;

$show .= "<div class=\"clear-block\">" . $show . "</div>";

$myFile = "/home/www/kodemas.com/test/testFile.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, $show);
fclose($fh);

}

flush() ;

#berakhir
?>